//
//  IWTitleButton.m
//  SINA
//
//  Created by 王相超 on 16/3/28.
//  Copyright © 2016年 chuanzhi. All rights reserved.
//

#import "IWTitleButton.h"
#define MARGIN 5

@implementation IWTitleButton


-(void)layoutSubviews{
    
    [super layoutSubviews];
    
    self.titleLabel.x = 0;
    
    self.imageView.x = CGRectGetMaxX(self.titleLabel.frame) +MARGIN;
    
    self.width = self.titleLabel.width + self.imageView.width +MARGIN;
    self.centerX = self.superview.width / 2;
    
    
}

- (void)setTitle:(NSString *)title forState:(UIControlState)state{
    
    [super setTitle:title forState:state];
    
    [self sizeToFit];
    
}

-(void)setImage:(UIImage *)image forState:(UIControlState)state{
    
    [super setImage:image forState:state];
    [self sizeToFit];
}


@end
